Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
eslint-plugin-node
Advanced tools
The eslint-plugin-node package is an ESLint plugin that contains rules that are specific to Node.js development. It helps in identifying issues related to syntax and patterns that are not optimal or could lead to errors in a Node.js context.
Process Exit As Throw
This rule treats calls to process.exit() as throw statements, which can be useful for highlighting an unexpected termination of the Node.js process.
/* eslint node/no-process-exit: 'error' */
process.exit(1);
No Deprecated API
This rule prevents the use of deprecated Node.js APIs to encourage best practices and avoid potential future issues with deprecated methods.
/* eslint node/no-deprecated-api: 'error' */
const domain = require('domain');
No Missing Imports
This rule ensures that all modules that are imported into a file are actually resolvable, helping to catch typos and incorrect module names.
/* eslint node/no-missing-import: 'error' */
import someModule from 'nonexistent-module';
No Unpublished Bin
This rule checks that all files referenced in the 'bin' field of package.json are actually published, preventing issues with npm packages.
/* eslint node/no-unpublished-bin: 'error' */
{
"bin": "bin/nonexistent.js"
}
This package provides similar functionality to eslint-plugin-node in terms of managing imports and exports in your code. It includes features like ensuring imports point to a file/module that can be resolved.
While eslint-plugin-node focuses on Node.js-specific rules, eslint-plugin-promise provides rules that are specific to the use of promises in JavaScript, which can be relevant in Node.js for handling asynchronous operations.
This package focuses on identifying potential security issues in Node.js code, which complements eslint-plugin-node's focus on Node.js best practices and avoiding deprecated or problematic patterns.
Additional ESLint's rules for Node.js
$ npm install --save-dev eslint eslint-plugin-node
^4.0.0 || >=6.0.0
>=3.1.0
Note: It recommends a use of the "engines" field of package.json. The "engines" field is used by no-unsupported-features rule.
.eslintrc.json (An example)
{
"plugins": ["node"],
"extends": ["eslint:recommended", "plugin:node/recommended"],
"rules": {
"node/exports-style": ["error", "module.exports"]
}
}
package.json (An example)
{
"name": "your-module",
"version": "1.0.0",
"engines": {
"node": ">=4.0.0"
}
}
Rule ID | Description | |
---|---|---|
no-extraneous-import | disallow import declarations of extraneous packages | |
⭐️ | no-extraneous-require | disallow require() expressions of extraneous packages |
no-missing-import | disallow import declarations of missing files | |
⭐️ | no-missing-require | disallow require() expressions of missing files |
⭐️ | no-unpublished-bin | disallow 'bin' files which are ignored by npm |
no-unpublished-import | disallow import declarations of private things | |
⭐️ | no-unpublished-require | disallow require() expressions of private things |
⭐️ | no-unsupported-features | disallow unsupported ECMAScript features on the specified version |
⭐️ | process-exit-as-throw | make process.exit() expressions the same code path as throw |
⭐️✒️ | shebang | enforce the correct usage of shebang |
Rule ID | Description | |
---|---|---|
⭐️ | no-deprecated-api | disallow deprecated APIs |
Rule ID | Description | |
---|---|---|
exports-style | enforce either module.exports or exports |
This plugin provides plugin:node/recommended
preset config.
This preset config:
process.exit()
.{ecmaVersion: 8}
into parserOptions
.no-missing-import
/ no-missing-require
rules don't work with nested folders in SublimeLinter-eslinteslint-plugin-node
follows semantic versioning and ESLint's Semantic Versioning Policy.
Welcome contributing!
Please use GitHub's Issues/PRs.
npm test
runs tests and measures coverage.npm run coverage
shows the coverage result of npm test
command.npm run clean
removes the coverage result of npm test
command.FAQs
Additional ESLint's rules for Node.js
The npm package eslint-plugin-node receives a total of 2,696,647 weekly downloads. As such, eslint-plugin-node popularity was classified as popular.
We found that eslint-plugin-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.